package com.leslie.speed.controller;


import com.leslie.common.annotation.Log;
import com.leslie.common.core.controller.BaseController;
import com.leslie.common.core.domain.AjaxResult;
import com.leslie.common.core.page.TableDataInfo;
import com.leslie.common.enums.BusinessType;
import com.leslie.common.utils.poi.ExcelUtil;
import com.leslie.speed.domain.QqSpeedVehicle;
import com.leslie.speed.service.IQqSpeedVehicleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆信息Controller
 * 
 * @author zb
 * @date 2024-01-14
 */
@RestController
@RequestMapping("/speed/vehicle")
public class QqSpeedVehicleController extends BaseController
{
    @Autowired
    private IQqSpeedVehicleService qqSpeedVehicleService;

    /**
     * 查询车辆信息列表
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:list')")
    @GetMapping("/list")
    public TableDataInfo list(QqSpeedVehicle qqSpeedVehicle)
    {
        startPage();
        List<QqSpeedVehicle> list = qqSpeedVehicleService.selectQqSpeedVehicleList(qqSpeedVehicle);
        return getDataTable(list);
    }

    /**
     * 导出车辆信息列表
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:export')")
    @Log(title = "车辆信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QqSpeedVehicle qqSpeedVehicle)
    {
        List<QqSpeedVehicle> list = qqSpeedVehicleService.selectQqSpeedVehicleList(qqSpeedVehicle);
        ExcelUtil<QqSpeedVehicle> util = new ExcelUtil<QqSpeedVehicle>(QqSpeedVehicle.class);
        util.exportExcel(response, list, "车辆信息数据");
    }

    /**
     * 获取车辆信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:query')")
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return success(qqSpeedVehicleService.selectQqSpeedVehicleByVehicleId(vehicleId));
    }

    /**
     * 新增车辆信息
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:add')")
    @Log(title = "车辆信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QqSpeedVehicle qqSpeedVehicle)
    {
        return toAjax(qqSpeedVehicleService.insertQqSpeedVehicle(qqSpeedVehicle));
    }

    /**
     * 修改车辆信息
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:edit')")
    @Log(title = "车辆信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QqSpeedVehicle qqSpeedVehicle)
    {
        return toAjax(qqSpeedVehicleService.updateQqSpeedVehicle(qqSpeedVehicle));
    }

    /**
     * 删除车辆信息
     */
    @PreAuthorize("@ss.hasPermi('speed:vehicle:remove')")
    @Log(title = "车辆信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(qqSpeedVehicleService.deleteQqSpeedVehicleByVehicleIds(vehicleIds));
    }
}
